package com.ruoyi.app.service.impl;

import com.ruoyi.app.domain.TypeFeedback;
import com.ruoyi.app.domain.UserFeedback;
import com.ruoyi.app.mapper.TypeFeedbackMapper;
import com.ruoyi.app.mapper.UserFeedbackMapper;
import com.ruoyi.app.service.UserFeedbackService;
import com.ruoyi.app.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserFeedbackServiceImpl implements UserFeedbackService {
    @Autowired
    private UserFeedbackMapper userFeedbackMapper;
    @Autowired
    private TypeFeedbackMapper typeFeedbackMapper;

    @Override
    public Result add(UserFeedback userFeedback) {
        try {
            int rows = userFeedbackMapper.add(userFeedback);
            if (rows > 0) {
                return Result.ok("反馈提交成功");
            } else {
                return Result.error("反馈提交失败");
            }
        } catch (Exception e) {
            return Result.error("系统错误，请稍后重试");
        }
    }

    /**
     * 查询全部类型反馈
     *
     * @return
     */
    @Override
    public List<TypeFeedback> listType() {
        return typeFeedbackMapper.selectList();
    }
}
